package com.wowo;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.ArrayList;
import java.util.List;

public class JacksonDemo {
    public static void main(String[] args) {
        ObjectMapper mapper = new ObjectMapper();

        //Java对象==>JSON
         // mapper.writeValueAsString()
         //mapper.readValue(str,Class)
        //java数组<==>JSON
        String[] arr = {"AJAX","JSON","Vue"};
       // String str = mapper.writeValueAsString(arr);
       // System.out.println("str=" + str);
      //  str ="[\"AJAX\",\"JSON\",\"Vue\",\"React\"]";
        //JSON ==>Java数组
       // String [] arr1= mapper.readValue(str,String[].class);
      //  System.out.println(Arrays.toString(arr1));
        //Java对象<==>JSON
        User user = new User(1,"tom",20);








        //Java List<User><===>Json
        List<User> users = new ArrayList<>();
        users.add(new User(1,"tom",19));
        users.add(new User(2,"alice",17));
        users.add(new User(3,"jack",21));
        //[{"id":1,"name":"tom","age":19},{},{}]


















    }

}
